Skip to content

combine: differentiate dyes by dye_profile instead of excluding them - #1617

Open
Alistair-Afton wants to merge 2 commits into
DFHack:masterfrom
Alistair-Afton:combine-dye-profile
Open

Alistair-Afton wants to merge 2 commits into
DFHack:masterfrom
Alistair-Afton:combine-dye-profile

Conversation

@Alistair-Afton

@Alistair-Afton Alistair-Afton commented Sep 15, 2026

Copy link
Copy Markdown

Summary

Implements the real fix for DFHack/dfhack#5849.

Since 52.03, dye powders carry an embedded dye_profile (color index plus the component material lists). Mixed dyes share mat_type/mat_index with their components, so combining stacks by material alone reverts a mixed dye to one of its components — the bug that #1596 avoided by excluding dyes from combining entirely.

This change fingerprints dye_profile into the comparison key for POWDER_MISC items, so dyes combine again — but only with an identical blend.

Dyes whose profile was lost to the vanilla merchant bug are never merged: the embedded dye_profile compound is always present on real items, so the unprofiled state is detected via color_index == -1, and each such item gets a unique comparison key. Non-dye powders (flour, etc.) are unaffected.

Test plan

  • test/combine.lua covers same/different profiles, mixed-vs-component keys, unprofiled dyes (both embedded-empty and absent profile), and non-dye powders
  • 6/6 tests pass in-game on 53.16

@ab9rf

ab9rf commented Sep 15, 2026

Copy link
Copy Markdown
Member

There are unfixed vanilla game bugs regarding dyes with incorrect or missing dye profiles (specifically, dyes and dyed cloth purchased from merchants sometimes have incorrect or missing dye information). Until those bugs are fixed, I'm not comfortable with possibly combining bugged and unbugged dye stacks, at least not until the consequences of doing this are known and understood.

@Alistair-Afton

Copy link
Copy Markdown
Author

@ab9rf Good point. Dyes missing their dye_profile now get a unique comparison key each, so they can never be merged into another stack or each other. Unprofiled non-dye powders (flour and such) are unaffected, and properly profiled dyes still combine per profile.

Blanket-excluding dyes prevented combining them at all. Mixed dyes share
mat_type/mat_index with their components, so keying POWDER_MISC items on
the dye_profile fingerprint keeps mixes distinct while allowing
identical dyes to stack.

fixes DFHack/dfhack#5849
Merchant dyes can end up with missing or incorrect dye info due to
unfixed vanilla bugs. Give such items a unique comparison key so they
stay uncombined rather than being merged into an unrelated stack.
@Alistair-Afton

Copy link
Copy Markdown
Author

Follow-up on the unprofiled-dye handling: the embedded dye_profile compound is never actually absent on real items — the missing-profile state shows up as color_index == -1 with empty vectors. The detection now keys off that, so merchant-bugged dyes each get a unique key as described. Pushed as part of a rebase onto current master.

Regarding dyes with incorrect (rather than missing) profiles: they still merge only with items carrying an identical profile, so a wrong profile can never collapse a different blend — the residual risk is two items sharing the same incorrect profile, which are indistinguishable to begin with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants